﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;

public partial class DynamicData_FieldTemplates_OrderQty : System.Web.DynamicData.FieldTemplateUserControl {
    public override Control DataControl {
        get {
            return Label1;
        }
    }

    // Set quantity stock thresholds.
    private int Min = 30;
    private int Max = 1500;

    // Get the current data field value 
    // and customize the display based on predefiend thresholds.
    protected override void OnDataBinding(EventArgs e)
    {
        // Read current quantity value.
        Int16 currentQty = (Int16)FieldValue;
        if (FieldValue != null)
        {

            if (currentQty <= Min)
            {
                // Quantity is less than the minimum 
                // stock threshold.
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Font.Bold = true;
            }
            else
                if (currentQty >= Max)
                {
                    // Quantity is greater than the maximum 
                    // stock threshold.
                    Label1.ForeColor = System.Drawing.Color.Blue;
                    Label1.Font.Bold = true;
                }
        }
    }



}
